package org.kk.design;

/**
 * 单例设计模式
 * 这里只推荐两种写法
 * @author kk
 * @Date 2021/1/21
 */
public class SingletonPattern {
}

/**
 * 线程安全懒汉式 内部类
 */
class Singleton1{
    private static class SingletionHolder{
        private static Singleton1 instance = new Singleton1();
    }
    public static Singleton1 getInstance(){
        return SingletionHolder.instance;
    }
    private Singleton1(){

    }
}

/**
 * 枚举
 */
enum Singletion2{
    INSTANCE;
    public void anyMethod(){}
}